package com.cqrcb.cloud.service.quota;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cqrcb.cloud.entity.api.req.Q;
import com.cqrcb.cloud.entity.api.res.R;
import com.cqrcb.cloud.entity.quota.CustomerMultiQuotaCtrlDetail;
import com.cqrcb.cloud.entity.quota.CustomerMultiQuotaCtrlMain;
import com.cqrcb.cloud.entity.quota.MultiQuotaCtrlMarketMain;
import com.cqrcb.cloud.entity.quota.io.CustomerMultiQuotaCtrlMarketMainIO;
import com.cqrcb.cloud.entity.quota.io.MultiQuotaCtrlMarketMainIO;

import java.util.List;

/**
* CustomerMultiQuotaCtrlMainService
*
* @author yangxueyong
* @date 2021-06-19 04:39:42
*/
public interface CustomerMultiQuotaCtrlMainService   {
    /**
     * 额度入库
     * @param record
     * @return
     */
    boolean saveFinancialProductQuota(CustomerMultiQuotaCtrlMain record);

    /**
     * 修改数据(推荐使用)
     * @param record
     */
    int updateByPrimaryKeySelective(CustomerMultiQuotaCtrlMain record);
    /**
     * 扣减金融产品额度
     * @param q
     * @return
     */
    R deductionFinancialProductQuota(Q<CustomerMultiQuotaCtrlMarketMainIO> q);

    /**
     * 计算额度并记录到redis
     * @param record
     * @return
     */
    List<CustomerMultiQuotaCtrlDetail> deductionQuota(CustomerMultiQuotaCtrlMarketMainIO record,List<CustomerMultiQuotaCtrlDetail> nowMultiQuotaCtrlMarketDetails);


    List<CustomerMultiQuotaCtrlDetail> saveMultiQuotaCtrlMarketDetailToRedis(CustomerMultiQuotaCtrlMarketMainIO record,List<CustomerMultiQuotaCtrlDetail> details);

    /**
//     * 记录额度到缓存中
//     * @param multiQuotaCtrlMarketMain
//     * @return
//     */
//    CustomerMultiQuotaCtrlMain saveMultiQuotaCtrlMarketMainToRedis(CustomerMultiQuotaCtrlMain multiQuotaCtrlMarketMain);

//    /**
//     * 从redis中取出额度
//     * @param record
//     * @return
//     */
//    List<CustomerMultiQuotaCtrlMain> getMultiQuotaCtrlMarketMainForRedis(CustomerMultiQuotaCtrlMarketMainIO record);

    List<CustomerMultiQuotaCtrlDetail> getMultiQuotaCtrlMarketDetailForRedis(CustomerMultiQuotaCtrlMarketMainIO record);

    /**
     * 从db中取出额度
     * @param record
     * @return
     */
    List<CustomerMultiQuotaCtrlDetail> getMultiQuotaCtrlMarketDetailForDB(CustomerMultiQuotaCtrlMarketMainIO record);

    List<CustomerMultiQuotaCtrlMain> getMultiQuotaCtrlMarketMainForDB(CustomerMultiQuotaCtrlMarketMainIO record);

    List<CustomerMultiQuotaCtrlDetail> calcMultiQuotaCtrlMarketMain(CustomerMultiQuotaCtrlMarketMainIO record);

    int updateMultiQuotaCtrlMarketDetailToDB(CustomerMultiQuotaCtrlMarketMainIO record,List<CustomerMultiQuotaCtrlDetail> customerMultiQuotaCtrlDetails);
}
